package com.wc.AlgoOJ_train.train1.c4.A412;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/1/10 15:37
 * @description
 */
public class Answer {
    public static String calculateDecimal(int n, int m) {
        StringBuilder result = new StringBuilder();
        int remainder = 1;

        // 模拟除法
        for (int i = 0; i < m; i++) {
            remainder *= 10;
            result.append(remainder / n);
            remainder = remainder % n;
        }

        return result.toString();
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
//            BigDecimal b = new BigDecimal("1");
            int n = sc.nextInt();
            int m = sc.nextInt();
            if (n == 1) {
                System.out.println(0);
                continue;
            }
            System.out.println(calculateDecimal(n, m).charAt(m - 1));
        }
    }
}
